PowerTCP Sockets for .NET
Send(Byte[],String,Int32) Method




A byte array containing the data to send.
The host address (either dot address or hostname) to send the datagram to.
The host port to send the datagram to.
Send a datagram to the specified remote address and port.
Syntax
'Declaration
 
Public Overloads Function Send( _
   ByVal buffer() As Byte, _
   ByVal hostNameOrAddress As String, _
   ByVal port As Integer _
) As Datagram
'Usage
 
Dim instance As UdpBase
Dim buffer() As Byte
Dim hostNameOrAddress As String
Dim port As Integer
Dim value As Datagram
 
value = instance.Send(buffer, hostNameOrAddress, port)
public Datagram Send( 
   byte[] buffer,
   string hostNameOrAddress,
   int port
)
public: Datagram* Send( 
   byte[]* buffer,
   string* hostNameOrAddress,
   int port
) 
public:
Datagram^ Send( 
   array<byte>^ buffer,
   String^ hostNameOrAddress,
   int port
) 

Parameters

buffer
A byte array containing the data to send.
hostNameOrAddress
The host address (either dot address or hostname) to send the datagram to.
port
The host port to send the datagram to.

Return Value

A Datagram object encapsulating the datagram sent.
Exceptions
ExceptionDescription
System.ArgumentNullExceptionbuffer is null.
System.Net.Sockets.SocketExceptionThe remote address is unknown, invalid, or unable to be resolved.
System.ArgumentOutOfRangeExceptionThe remote port is out of the range of valid values.
Remarks

Use the Send method to sent a datagram created from the data contained in buffer to the specified hostNameOrAddress and port.

A UDP datagram provides little functionality over an IP datagram, adding a port number field (allows demultiplexing on the receiving host) and a checksum field (provides basic error handling). Unlike TCP, UDP datagrams are sent as a unit. If Send is called 3 times to send 3 datagrams to a host, the receiving host will have to call Receive 3 times. Also, the size of each datagram sent will equal the size of each datagram received by the receiving host. In addition, since UDP is a connectionless protocol, any datagrams sent to the host are not guaranteed to be delivered. Therefore, any required error checking (outside of UDP's checksum implementation) will have to be done by the application-layer protocol.

To send a broadcast datagram, use "255.255.255.255" as the remote address. To send a multicast datagram, use the multicast group address as the remote address after first joining a multicast group by using JoinMulitcastGroup.

See Also

Reference

UdpBase Class
UdpBase Members
Overload List


PowerTCP Sockets for .NET Documentation Version 4.5
© 2018 Dart Communications. All Rights Reserved.
Send comments on this topic